package com.own.business.question.common.handler;

import com.own.business.question.common.exception.QuestionException;
import com.own.component.common.model.ExceptionMessageModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * QuestionExceptionHandler
 *
 * @author 陈学礼 （你是一段成熟的代码，要学会自己改bug）
 * @version 4.0.0
 * @date 2021-6-17 16:37:10
 * @since 4.0.0
 */
@Slf4j
@Order(1)
@RestControllerAdvice
public class QuestionExceptionHandler {

    /**
     * 处理 ExamException 异常
     *
     * @param e 异常信息
     * @return 返回信息
     */
    @ExceptionHandler(QuestionException.class)
    public ExceptionMessageModel handleBusinessException(QuestionException e) {
        log.error(e.getMessage(), e);
        return new ExceptionMessageModel(e);
    }

}
